<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<style type="text/css">
<!--
body {

	font-family: "Trebuchet MS","Helvetica","Arial","Verdana","sans-serif";
  font-size: 62.5%;
}
-->
</style>
<base href="<%=basePath%>">
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
		<title>活动管理</title>
		<link rel="stylesheet" type="text/css" href="../css/base.css">		
		<link rel="stylesheet" href="css/jquery-ui.css" />
    <script language="javascript" src="js/jquery-1.7.2.min.js"></script>
		<script language="javascript" src="js/jquery-ui-1.8.22.custom.min.js"></script>
		<script language="javascript" src="js/jquery-ui.js"></script>
		<script language="javascript" src="js/jquery.ui.datepicker-zh-CN.js"></script>
		<script language="javascript" src="js/common.js"></script>
		
<script type="text/JavaScript">
// 页面初始化加载的时候调用的方法
$(document).ready(function(){
	alert("页面加载成功");
	$.datepicker.setDefaults({
		closeText: "关闭", prevText: "&#x3c;上月", nextText: "下月&#x3e;", currentText: "今天",
	 	monthNames: ["一月", "二月", "三月", "四月", "五月", "六月", "七月", "八月", "九月", "十月", "十一月", "十二月"],
	  monthNamesShort: ["一", "二", "三", "四", "五", "六", "七", "八", "九", "十", "十一", "十二"], 
	  dayNames: ["星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六"], 
	  dayNamesShort: ["周日", "周一", "周二", "周三", "周四", "周五", "周六"], 
	  dayNamesMin: ["日", "一", "二", "三", "四", "五", "六"], weekHeader: "周",
	  dateFormat: "yy-mm-dd", firstDay: 1, isRTL: !1, showMonthAfterYear: !0, yearSuffix: "年" 
		});
	$.datepicker.setDefaults($.datepicker.regional["zh-CN"]);   
	$("#startDate").datepicker({
		dateFormat:"yy-mm-dd"	
	});
	$("#endDate").datepicker({dateFormat:"yy-mm-dd"});
	
	// 给添加广告位按钮绑定一个单击事件
  $("#addBtn").bind("click",function(){
    document.searchActiveForm.action = "jumpToActive.action";
		document.searchActiveForm.submit();
  });
  
  // 给搜索按钮绑定一个单击事件
  $("#searchBtn").click(function(){
  	alert(2);
    document.searchActiveForm.action = "activeAct!searchActive.action";
		document.searchActiveForm.submit();
  });
  
   // 给搜索按钮绑定一个单击事件
  $("#delBtn").bind("click",function(){
  	alert("删除");
    document.searchActiveForm.action = "activeAct!delActive.action";
		document.searchActiveForm.submit();
  });
  
});

function initUptActive(id){
	document.searchActiveForm.action = "activeAct!initUptActive.action?activeVo.id=" + id;
	document.searchActiveForm.submit();
} 

//翻页效果
function chgPage(btnFlg){
  var curPage = parseInt($("#curPage").val());
  var totalPages = parseInt($("#totalPages").val());
  if(btnFlg == 1){
	  if(curPage==1){
	    alert("已经是首页");
	    return;
	  }
	  // 设置当前页为第一页
	  $("#curPage").val(1);
	} else if(btnFlg == 2){
	  if(curPage==1){
	    alert("已经是第一页");
	    return;
	  }
	  // 设置当前页为当前页-1
	  $("#curPage").val(curPage - 1);
	} else if(btnFlg == 3){
	  if(curPage==totalPages){
	    alert("已经是最后一页");
	    return;
	  }
	  // 设置当前页为当前页+1
	  $("#curPage").val(curPage + 1);
  } else if(btnFlg == 4){
  		if(curPage==totalPages){
	    alert("已经是末页");
	    return;
	  }
	  // 设置当前页为最后一页
	  $("#curPage").val(totalPages);
  } else if(btnFlg == 5){
  	var chgPageNum = parseInt($("#chgPageNum").val());
  	if(chgPageNum<1 || chgPageNum>totalPages){
  	  alert("您输入的页码不存在，请重新输入");
	    return;
  	} else if(curPage==chgPageNum){
	    alert("当前页已经是您所要跳转的页面了");
	    return;
	  }
	  // 设置当前页为最后一页
	  $("#curPage").val(chgPageNum);
  }
  document.searchActiveForm.action = "activeAct!searchActive.action";
	document.searchActiveForm.submit();
}
</script>
	</head>
	<body leftmargin="8" topmargin="8" background='images/allbg.gif'>
	<s:form name="searchActiveForm" id="searchActiveForm" method="post" action="">
	<s:hidden name="activeVoQry.totalPages" id="totalPages" value="%{activeVoQry.totalPages}" />
	<s:hidden name="activeVoQry.curPage" id="curPage" value="%{activeVoQry.curPage}" />
		<!--  快速转换位置按钮  -->
		<table width="98%" border="0" cellpadding="0" cellspacing="1"
			bgcolor="#D1DDAA" align="center">
			<tr>
				<td height="26" background="images/newlinebg3.gif">
					<table width="98%" border="0" cellspacing="0" cellpadding="0">
						<tr>
							<td align="center">
								<input type='button' name="addBtn" id="addBtn" value='添加活动信息' />
								<input type='button' name="delBtn" id="delBtn" value='删除活动信息' />
								<input type='button' onClick="location='';" value='活动审核' />
							</td>
						</tr>
					</table>
				</td>
			</tr>
		</table>
		<!--  内容列表   -->
			<table id="contentListId" width="98%" border="0" cellpadding="2" cellspacing="1"
				bgcolor="#D1DDAA" align="center" style="margin-top: 8px">
				<tr bgcolor="#E7E7E7">
					<td height="24" colspan="10" align="center"
						background="images/tbg.gif">
						&nbsp;活动信息列表&nbsp;
					</td>
				</tr>
				<tr align="center" bgcolor="#FAFAF1" height="22">
					<td width="4%" align="center">
						编号
					</td>
					<td width="4%" align="center">
						选择
					</td>
					<td width="12%" align="center">
						活动名称
					</td>
					<td width="7%" align="center">
						开始时间
					</td>
					<td width="7%" align="center">
						结束时间
					</td>
					<td width="6%" align="center">
						发起人
					</td>
					<td width="6%" align="center">
						创建时间
					</td>
					<td width="5%" align="center">
						创建人
					</td>
					<td width="7%" align="center">
						状态
					</td>
					<td width="8%" align="center">
						操作
					</td>
				</tr>							
				<s:iterator value="activeVoList" status="nowIndex">
				<tr align='center' bgcolor="#FFFFFF"
					onMouseMove="javascript:this.bgColor='#FCFDEE';"
					onMouseOut="javascript:this.bgColor='#FFFFFF';" height="22">
					<td>
						${(nowIndex.index+1)+(activeVoQry.curPage-1)*activeVoQry.numPerPage}
					</td>
					<td>               
						<s:checkbox name="selectId" fieldValue="%{id}" theme="simple" />
					</td>
					<td align="left">
						<s:property value="%{activeName}" />---id=<s:property value="%{id}" />
					</td>
					<td align="center">
						<s:date name="%{startDate}" format="yyyy-MM-dd" />
					</td>
					<td align="center">
						<s:date name="%{endDate}" format="yyyy-MM-dd" />
					</td>
					<td>
						<s:property value="%{sponsors}" />
					</td>
					<td>
						2012-11-11
						<!--<s:property value="创建时间" /> -->
					</td>		
					<td>
						admin
						<!--  <s:property value="创建人" /> -->
					</td>		
					<td>
						<s:property value="%{stateValue}" />
					</td>		
					<td>
						<a href="javascript:initUptActive(<s:property value='%{id}' />)">编辑</a> |
						<a href="">预览</a>
					</td>
				</tr>
				</s:iterator>
				<!-- 判断数据库中是否有符合条件的记录 -->
				<s:set name="activeVoListFlg" value="%{activeVoQry.totalPages}"/>
				<!--判断数据库是否有满足条件的记录 -->
				<s:if test="not empty(activeVoQry.totalPages)"> 
				<tr bgcolor="#FAFAF1">
					<td height="28" colspan="10">
						&nbsp;
						<a href="javascript:selAll('selectId')" class="coolbg">全选</a>
						<a href="javascript:unSelectAll('selectId')" class="coolbg">反选</a>
						<a href="javascript:cancelAll('selectId')" class="coolbg">取消</a>
						<a href="javascript:updateArc(0)" class="coolbg">&nbsp;更新&nbsp;</a>
						<a href="javascript:checkArc(0)" class="coolbg">&nbsp;审核&nbsp;</a>
						<a href="javascript:adArc(0)" class="coolbg">&nbsp;推荐&nbsp;</a>
						<a href="javascript:moveArc(0)" class="coolbg">&nbsp;移动&nbsp;</a>
						<a href="javascript:delArc(0)" class="coolbg">&nbsp;删除&nbsp;</a>
					</td>
				</tr>
				<tr align="right" bgcolor="#EEF4EA">
					<td height="36" colspan="10" align="center">
						<!--翻页代码 -->
						<table width="100%" border="0" align="center" cellpadding="0" cellspacing="0" class="right-font08">
	            <tr>
	              <td width="50%">共 <span class="right-text09"><s:property value="%{activeVoQry.totalPages}" /></span> 页 | 第 <span class="right-text09"><s:property value="%{activeVoQry.curPage}" /></span> 页</td>
	              <td width="49%" align="right">[<a href="javascript:chgPage(1);" class="right-font08">首页</a> | <a href="javascript:chgPage(2);" class="right-font08">上一页</a> | <a href="javascript:chgPage(3);" class="right-font08">下一页</a> | <a href="javascript:chgPage(4);" class="right-font08">末页</a>] 转至：</td>
	              <td width="1%">
	                <table width="20" border="0" cellspacing="0" cellpadding="0">
	                  <tr>
	                    <td width="5%"><input name="chgPageNum" id="chgPageNum" type="text" class="right-textfield03" size="1" /></td>
	                    <td width="87%"><input name="Submit23222" type="button" onclick="javascript:chgPage(5);" class="right-button06" value="跳转" />
	                    </td>
	                  </tr>
	                </table>
	              </td>
	            </tr>
	        	</table>        	
					</s:if>
					</td>
				</tr>
			</table>
	
		<!--  搜索表单  -->
			<input type='hidden' name='dopost' value='' />
			<table width='98%' border='0' cellpadding='1' cellspacing='1'
				bgcolor='#CBD8AC' align="center" style="margin-top: 8px">
				<tr bgcolor='#EEF4EA'>
					<td background='images/wbg.gif' align='center'>
						<table border='0' cellpadding='0' cellspacing='0'>
							<tr>
								<td width='10%' align='left'>
									搜索条件
								</td>
								<td  width='10%' align='right'>
									开始时间：
								</td>
								<td width='6%'>
									 <s:textfield name="activeVoQry.startDate" id="startDate" theme="simple" />
								</td>
								<td width='10%' align='right'>
									结束时间：
								</td>
								<td width='6%'>	 
									 <s:textfield name="activeVoQry.endDate" id="endDate" theme="simple"></s:textfield>
								</td>
								<td width='10%' align='right'>								
									活动名称：
								</td>
								<td width='10%'>
									<s:textfield name="activeVoQry.activeName" theme="simple" />								
								</td>
								<td>
									状态：
								</td>
								<td width='10%'>							
									<select name='activeVoQry.state' style='width: 80px'>
										<option value='0'>
											关闭
										</option>
										<option value='1'>
											正常
										</option>
									</select>
								</td>
								<td>
									<input type="button" class="np" name="searchBtn" width="80" height="25"  id="searchBtn" value="搜索"/>
								</td>
							</tr>
						</table>
					</td>
				</tr>
			</table>
		</s:form>
	</body>
</html>